<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
  .container {
    overflow: hidden; /* 触发BFC */
  }
  .float-box {
    float: left;
    width: 100px;
    height: 100px;
    background-color: lightblue;
    margin: 10px;
  }
  .text {
    background-color: lightcoral;
  }
</style>
<body>
    <!--
        什么是BFC？
            BFC（Block Formatting Context:区块格式化上下文）是一个独立的渲染区域，BFC内的元素布局不受外部元素影响，反之亦然。
            隔绝了内外部的联系，不同的bfc区域，渲染时候，也互不干扰。它在解决一些CSS布局问题时非常有用，比如清除浮动、避免元素重叠等。

        触发BFC的方式
            根元素html本身开启了BFC
            浮动元素：float: left; 或 float: right;
            绝对定位元素：position: absolute; 或 position: fixed;
            overflow 不是 visible 的元素：如 overflow: hidden;
            弹性盒模型元素：display: flex; 或 display: inline-flex;
            网格布局元素：display: grid; 或 display: inline-grid 或 display:table;
            多列容器：column-count
            display: flow-root

        为什么需要BFC？
            (高度需要会自动计算浮动的内容)
            <!DOCTYPE html>
                <html lang="en">
                <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>Document</title>
                </head>
                <style>
                .contaniner {
                    background-color: blue;
                    overflow: scroll;
                }
                .item {
                    background-color: aqua;
                    float: left;
                    width: 100px;
                    height: 100px;
                    margin: 10px;
                }
                </style>
                <body>
                <div class="contaniner">
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                    <div class="item"></div>
                </div>
                </body>
                </html>
            （它的边框不会与浮动元素重叠）
            <!DOCTYPE html>
                <html lang="en">
                <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>Document</title>
                </head>
                <style>
                .contaniner {
                    background-color: blue;
                    float: left;
                    width: 200px;
                    height: 200px;
                    margin-right: 20px;
                }
                .item {
                    background-color: aqua;
                    width: 500px;
                    height: 500px;
                    overflow: scroll;
                }
                </style>
                <body>
                <div class="contaniner">
                </div>
                <div class="item"></div>
                </body>
                </html>
            （不会和它的子元素进行外边距合并）   
            <!DOCTYPE html>
                <html lang="en">
                <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>Document</title>
                </head>
                <style>
                .contaniner {
                    background-color: blue;
                    width: 500px;
                    height: 500px;
                    margin-top: 20px;
                    overflow: hidden;
                }
                .item {
                    background-color: aqua;
                    width: 200px;
                    height: 200px;
                    margin-top: 20px;
                }
                </style>
                <body>
                <div class="contaniner">
                    <div class="item"></div>
                </div>
                </body>
                </html>
    -->

        <div class="float-box"></div>
        <div class="text">这段文字不会环绕浮动元素。</div>

</body>
</html>